package com.lsyw.intergrate.mapper;

import com.lsyw.intergrate.entity.JcMassifFactorValueLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 监测数据日志表 Mapper 接口
 * </p>
 *
 * @author 刘磊
 * @since 2023-12-20
 */
@Mapper
public interface JcMassifFactorValueLogMapper extends BaseMapper<JcMassifFactorValueLog> {
    @Select("select * from jc_massif_factor_value_log where device_no=#{code} and cn=#{cn} and del_flag=0 and EXISTS (select 1 from jc_massif_factor_value where value is not null and jc_massif_factor_value.jc_massif_factor_value_log=jc_massif_factor_value_log.id) order by gmt_create desc limit 1")
    JcMassifFactorValueLog getOneByDeviceNoAndCn(@Param("code") String code, @Param("cn") String cn);
    @Select("select * from jc_massif_factor_value_log where massif_id=#{massifId} and cn=#{cn} and del_flag=0  and device_no like '654934605017%' and EXISTS (select 1 from jc_massif_factor_value where value is not null and jc_massif_factor_value.jc_massif_factor_value_log=jc_massif_factor_value_log.id) order by gmt_create desc limit 1")
    JcMassifFactorValueLog getOneByMassif(@Param("massifId") String massifId, @Param("cn") String cn);
}
